<template>
    <div>
        <el-table :data="tableData" stripe style="width: 100%">
            <el-table-column prop="registName" label="号别名称" width="230px" ></el-table-column>
            <el-table-column prop="registCode" label="号别编码" width="230px" ></el-table-column>
            <el-table-column prop="registFee" label="挂号费" width="230px" ></el-table-column>
            <el-table-column prop="registQuota" label="挂号限额" width="230px" ></el-table-column>
            <el-table-column prop="delMark" label="删除状态" width="230px"></el-table-column>
            <el-table-column label="操作">
                <template slot-scope="scope">
                    <el-button type="primary" @click="updatexiugai(scope.$index,scope.row)">修改</el-button>
                    <el-button type="danger" @click="deleteshanchu(scope.$index, scope.row)">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
         <div class="block">
            <el-pagination
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="currentPage4"
              :page-sizes="[100]"
              :page-size="100"
              layout="total, sizes, prev, pager, next, jumper"
              :total="10">
            </el-pagination>
          </div>
        <el-dialog title="编辑挂号信息" :visible.sync="handleEdit">
            <el-form :model="updateregistLevel">
                <el-form-item label="号别名称" :label-width="formLabelWidth">
                    <el-input v-model="updateregistLevel.RegistName" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="号别编码" :label-width="formLabelWidth">
                    <el-input v-model="updateregistLevel.RegistCode" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="挂号费" :label-width="formLabelWidth">
                    <el-input v-model="updateregistLevel.RegistFee" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="挂号限额" :label-width="formLabelWidth">
                    <el-input v-model="updateregistLevel.RegistQuota" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="排序序号" :label-width="formLabelWidth">
                    <el-input v-model="updateregistLevel.SequenceNo" autocomplete="off"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="handleEdit=false">取 消</el-button>
                <el-button type="primary" @click="updataqueding()">确 定</el-button>
            </div>
        </el-dialog>
    </div>
</template>


<script>
import registLevel from '@/api/his/registLevel';

export default {
    name: 'Resgister',
    inject:['reload'],//引用父组件传过来reload方法进行页面更新
    data() {
        return {
          currentPage1: 5,
                  currentPage2: 5,
                  currentPage3: 5,
                  currentPage4: 4,
           tableData: [],
            cindex: 0,
            updatexiugai1: false,
            deleteshanchu1: false,
            handleEdit:false,
            form: {
              name: '',
              id: '',
              fee: '',
              Quota: '',
              No: '',
                delivery: false,
                type: [],
                resource: '',
                desc: ''
            },
            //删除对象
            deleteregistLevel:{
                  id:0,
            },
            //查询对象
            selectdata:{
              page:1,
              limit:10
            },
            //修改对象
            updateregistLevel:{
                ID:0,
                RegistCode:'',
                RegistName:'',
                SequenceNo:'',
                RegistFee:'',
                RegistQuota:'',
            },
            formLabelWidth: '120px'
        };

    }, methods: {
        //修改函数
        handleSizeChange(val) {
                console.log(`每页 ${val} 条`);
              },
              handleCurrentChange(val) {
                console.log(`当前页: ${val}`);
              },
        updatexiugai(index,row){
          this.handleEdit=true
            this.updateregistLevel.ID=row.id
            this.updateregistLevel.RegistCode=row.registCode
            this.updateregistLevel.RegistName=row.registName
            this.updateregistLevel.SequenceNo=row.sequenceNo
            this.updateregistLevel.RegistFee=row.registFee
            console.log(this.updateregistLevel)
        },
        updataqueding(){
          this.handleEdit=false
          registLevel.getupdate(this.updateregistLevel).then((res)=>{
            console.log(res)
            if(res.data.data.upd==true){
              alert("修改成功")
              this.reload()
            }else{
              alert("修改失败")
            }
          })

        },
        //删除函数
        deleteshanchu(index, row){
            this.deleteregistLevel.id=row.id
            registLevel.getdelete(this.deleteregistLevel).then((res)=>{
              console.log(res)
              if(res.data.data.flag==true){
                alert("删除成功")
                }else{
                alert("删除失败")
                }
            })
            this.reload()
        }
    },
    beforeMount(){
      registLevel.getselect(this.selectdata).then((res)=>{
        this.tableData=res.data.data.list
      })
    }
}
</script>


<style scoped></style>
